package lib.gui;

import java.io.File;

import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;

import lib.Base.Workplace;
import lib.Common.Cast;
import lib.Common.Path;

import org.swixml.SwingEngine;

public class GuiProfileWorkplace {
	/**
	 * Class which represents a career entry in the profile page
	 */
	private JLabel name;
	private JLabel profession;
	private JLabel dateBegin;
	private JLabel dateEnd;

	public GuiProfileWorkplace(Workplace workplace) {

		try {
			new SwingEngine(this).render(new File(Path.GUI_PATH
					+ "gui-profile-workplace.xml")).setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}

		this.name.setText(workplace.getName());
		this.profession.setText(workplace.getProfession());
		this.dateBegin.setText(Cast.formatTimeStampAs_ddmmyyyy(workplace
				.getBegin()));
		this.dateEnd.setText(Cast
				.formatTimeStampAs_ddmmyyyy(workplace.getEnd()));
	}
	
	public JComponent getPanel(){
		return (JPanel)name.getParent();
	}
}